package com.fau.cm.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.time.DateFormatUtils;
import org.hibernate.annotations.GenericGenerator;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc  呼出电话明细表
 * @author yangzj
 * @datetime 2014年10月15日,上午9:53:12
 */
@Entity
@Table(name = "medical_call_exhale")
public class MedicalCallExhale implements Serializable, JSONAware{
	
	private static final long serialVersionUID = -6228503016543866177L;

	private String id;						//呼出电话明细表id
	private String extensionNumber;			//分机号
	private String outgoingCalls;			//呼出电话
	private Date outgoingTime;				//呼出时间
	private Date hangUpTime;				//挂起时间
	private Integer callDuration;			//呼叫时长
	private String operator;				//操作员id
	private String groupId;					// 组id
	private String centerId;				// 中心id
	private String operatorName;			//操作员姓名
	private String province;				//省
	private String city;					//市
	private String hospitalId;				// 医院企业id
	
	private Date startTime;					//开始时间
	private Date endTime;					//开始时间
	private Integer bigCallDuration;		//大于呼叫时长
	private Integer smallCallDuration;		//小于呼叫时长
	private String ids;						//多个id
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}
	
	@Column(name = "extension_number", length = 20)
	public String getExtensionNumber() {
		return extensionNumber;
	}
	
	public void setExtensionNumber(String extensionNumber) {
		this.extensionNumber = extensionNumber;
	}
	
	@Column(name = "outgoing_calls", length = 20)
	public String getOutgoingCalls() {
		return outgoingCalls;
	}
	
	public void setOutgoingCalls(String outgoingCalls) {
		this.outgoingCalls = outgoingCalls;
	}

	@Column(name = "outgoing_time")
	public Date getOutgoingTime() {
		return outgoingTime;
	}

	public void setOutgoingTime(Date outgoingTime) {
		this.outgoingTime = outgoingTime;
	}

	@Column(name = "hang_up_time")
	public Date getHangUpTime() {
		return hangUpTime;
	}
	
	public void setHangUpTime(Date hangUpTime) {
		this.hangUpTime = hangUpTime;
	}
	
	@Column(name = "call_duration", length = 11)
	public Integer getCallDuration() {
		return callDuration;
	}
	
	public void setCallDuration(Integer callDuration) {
		this.callDuration = callDuration;
	}
	
	@Column(name = "operator", length = 32)
	public String getOperator() {
		return operator;
	}
	
	public void setOperator(String operator) {
		this.operator = operator;
	}
	
	@Column(name = "group_id", length = 32)
	public String getGroupId() {
		return groupId;
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}
	
	@Column(name = "center_id", length = 32)
	public String getCenterId() {
		return centerId;
	}

	public void setCenterId(String centerId) {
		this.centerId = centerId;
	}

	@Column(name = "province", length = 32)
	public String getProvince() {
		return province;
	}
	
	public void setProvince(String province) {
		this.province = province;
	}
	
	@Column(name = "city", length = 32)
	public String getCity() {
		return city;
	}
	
	public void setCity(String city) {
		this.city = city;
	}
	
	@Column(name = "hospital_id", length = 32)
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}

	@Transient
	public Date getStartTime() {
		return startTime;
	}
	
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	
	@Transient
	public Date getEndTime() {
		return endTime;
	}
	
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	
	@Transient
	public Integer getBigCallDuration() {
		return bigCallDuration;
	}

	public void setBigCallDuration(Integer bigCallDuration) {
		this.bigCallDuration = bigCallDuration;
	}

	@Transient
	public Integer getSmallCallDuration() {
		return smallCallDuration;
	}

	public void setSmallCallDuration(Integer smallCallDuration) {
		this.smallCallDuration = smallCallDuration;
	}
	
	@Transient
	public String getIds() {
		return ids;
	}

	public void setIds(String ids) {
		this.ids = ids;
	}

	@Transient
	public String getOperatorName() {
		return operatorName;
	}

	public void setOperatorName(String operatorName) {
		this.operatorName = operatorName;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		obj.put("id", id);
		obj.put("extensionNumber", extensionNumber);
		obj.put("outgoingCalls", outgoingCalls);
		if(outgoingTime != null){
			obj.put("outgoingTime", DateFormatUtils.format(outgoingTime, "yyyy-MM-dd HH:mm:ss"));
		}
		if(hangUpTime != null){
			obj.put("hangUpTime", DateFormatUtils.format(hangUpTime, "yyyy-MM-dd HH:mm:ss"));
		}
		obj.put("callDuration", callDuration);
		obj.put("operator", operator);
		obj.put("operatorName", operatorName);
		obj.put("province", province);
		obj.put("city", city);
		return obj.toString();
	}
}
